
@echo off

cls

            set START_CD=%CD%

echo .
echo .
echo .      Erasing the main dist-lib directory
echo .      ===================================
echo .
            erase dist-lib\* /q /s
            erase dist\* /q /s
            
            IF %ERRORLEVEL% NEQ 0 GOTO ERROR_HANDLER

            GOTO CODE_GENERATION
            

:CODE_GENERATION
echo .
echo .
echo .      Cleaning the Code Generation Project
echo .      ====================================
echo .
            cd icani.codegeneration
            
            call clean.cmd 
            
            IF %ERRORLEVEL% NEQ 0 GOTO ERROR_HANDLER
            
            cd ..

            GOTO DOMAIN_MODEL


:DOMAIN_MODEL
echo .
echo .
echo .      Cleaning the Domain Model
echo .      =========================
echo .
            cd icani.domainmodel
            
            call clean.cmd 
            
            IF %ERRORLEVEL% NEQ 0 GOTO ERROR_HANDLER
            
            cd ..

            GOTO DATA_MODEL


:DATA_MODEL
echo .
echo .
echo .      Cleaning the Data Model
echo .      =======================
echo .
            cd icani.datamodel
            
            call clean.cmd 
            
            IF %ERRORLEVEL% NEQ 0 GOTO ERROR_HANDLER
            
            cd ..
            
            GOTO EVENT_MODEL


:EVENT_MODEL
echo .
echo .
echo .      Cleaning the Event Model
echo .      ========================
echo .
            cd icani.eventmodel
            
            call clean.cmd 
            
            IF %ERRORLEVEL% NEQ 0 GOTO ERROR_HANDLER
            
            cd ..
            
            GOTO SERVICE_MODEL


:SERVICE_MODEL
echo .
echo .
echo .      Cleaning the Service Model
echo .      ==========================
echo .
            cd icani.servicemodel
            
            call clean.cmd 
            
            IF %ERRORLEVEL% NEQ 0 GOTO ERROR_HANDLER
            
            cd ..
            
            GOTO CORE


:CORE
echo .
echo .
echo .      Cleaning the Core Project
echo .      =========================
echo .
            cd icani.core
            
            call clean.cmd 
            
            IF %ERRORLEVEL% NEQ 0 GOTO ERROR_HANDLER
            
            cd ..
            
            GOTO QUIT


:ERROR_HANDLER
echo .
echo .
echo .      M: Error occured!
echo .
echo .
            GOTO QUIT_ERROR

            
:QUIT_ERROR
echo .
echo .
echo .      M: Clean all aborted due error
echo .
echo . 
            GOTO QUIT

            
:QUIT_NORMAL
echo .
echo .
echo .      M: Clean all done normal
echo .
echo . 
            GOTO QUIT

            
:QUIT
            cd %START_CD%
            